#!/bin/sh

# macOS specific paths
HTML_DIR="/opt/homebrew/var/www"
CONFIG_DIR="/opt/homebrew/etc/nginx/"
NGINX_CONF="nginx_mac.conf"

# Create HTML directory if it doesn't exist
mkdir -p "$HTML_DIR"

# Update HTML files - use the html directory directly instead of html.war
echo "update html"
rm -rf "$HTML_DIR"/*
cp -r ../html/* "$HTML_DIR/"

# Update nginx configuration
echo "update nginx_config"
cp -f "$NGINX_CONF" "$CONFIG_DIR/nginx.conf"

# Reload nginx
echo "reload nginx"
cd "/opt/homebrew/bin" && ./nginx -s reload

# Pause for 5 seconds to let user see the output
echo "Deployment completed. Pausing for 5 seconds..."
sleep 5